$(function (){  
    var submits = 0;
    $('input[name=title]').keyup(function() {
        $('#headinginner span').text($(this).val());
        if($('#headinginner span').text()=='')$('#headinginner span').text('Naziv ankete');
    });  
    /*VALIDATE FORM ANKETA*/
    $('#editVest').submit(function(){
        $('.ValidationErrors').css('display','none');
        var valid = true;
        if(!$("#title").checkQuestion()){
            create_error('question_error','Molimo unestite naslov.'); 
            valid = false; 
        }
        /*if(!$("#text").checkQuestion()){
            create_error('erroranswertext','Molimo unestite sadržaj.');
            valid = false; 
        }*/
        if(valid){ 
            $('#editVest').submit();
        }else{
            $('html, body').animate({scrollTop:0}, 'slow');
            return false;
        }

    })
    /*DISPLAY FORM ERRORS*/    
    function create_error(id,message){
        $('#'+id).html(message);
        $('#'+id).css('display','block');        
    }
    /*DISPLAY CONSLOE MESSAGES*/
    //console.log("Hello there!")    

    tinyMCE.init({
        mode : "textareas",
        theme : "advanced",
        plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",
        theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,code",
        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,|,fullscreen",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : false,
        content_css : base_url+"assets/js/tinymce/themes/advanced/skins/default/custom_content.css",
    });
})
